<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>团课预约列表</title>
	<meta content="width=device-width,initial-scale=1.0,minimum-scale=1.0.maximum-scale=1.0,user-scalable=no" name="viewport">
	<script src="js/flexible.js"></script>
	<link rel="stylesheet" href="css/reset.css">
	<link rel="stylesheet" href="css/homePage.css">
	<link rel="stylesheet" href="css/flexible.css">
	<link rel="stylesheet" href="css/vant.css">
	<script src="js/jquery-3.3.1.min.js"></script>
	<script src="js/vue/vue.js"></script>
	<script src="js/vue/axios.js"></script>
	<script src="js/vue/MD5.js"></script>
	<script src="js/vue/vant.js"></script>
</head>
<body>
	<div class="container_box" id="app">
		<template>
				<div class="group_details group_details_state paddingtop20 clearfix" v-for="item in listData">
						<div class="fl" style="width:22%;">
							<img :src="item.Picurl" onerror="this.src='images/moren.png'" alt="" class="spinning_img">
						</div>
						<div class="fl" style="width:78%;">
							<div class="fl">
								<p>
									<span class="spinning_name">{{item.Username}}</span>
									<span class="spinning_txx">
										<img v-if="item.Sex=='0'" src="images/woman.png">
										<img v-else src="images/man.png">
									</span>
								</p>
								<p>
									<span class="spinning_A" style="background-color: white;">{{item.Cardname}}</span>
									<span class="spinning_date">剩余{{item.Surplus}}{{item.Surplus_C}}</span>
								</p>
								<p class="degree">预约时间<span class="many_full">{{item.Adddate}}</span></p>
							</div>
							<div v-if="item.IsReserve=='0'" @click="pSignIn(item.id,item.Currid)" class="private_Sign fr" >签到</div>
							<div v-if="item.IsReserve=='0'" @click="pCancel(item.id,item.Currid)" class="private_Sign private_Sign1 fr">取消预约</div>
							<div v-else-if="item.IsReserve=='1'" class="private_Sign private_Sign1 fr">已签到</div>
							<div v-else-if="item.IsReserve=='3'" class="private_Sign private_Sign1 fr">已违约</div>
							<div v-else class="private_Sign private_Sign1 fr">已取消</div>
						</div>
					</div>
		</template>
	</div>
	<div class="technology">馆家提供技术支持</div>
</body>
<script>
new Vue({
    el: '#app',
    data: {
		besid:'',
		listData:[]
    },
    created(){
        this.setCanS()
    },
    methods:{
		 //设置参数
		setCanS(){
            let Request = new Object()
            Request = GetRequest()
			this.besid = Request['besid']
			this.getList()
        },
        getList() {
			const params={
				besid:this.besid,
			}
			getVs()
			axios.get('/mobileapi/coach/sign.php?act=curr_t_list',{params:params}).then(data =>{
				console.log(data.data)
				let { msg, code,user} = data.data
					if (code !== 200) {
					    window.vant.Toast.fail(msg)
					} else {
						data=data.data
						this.listData=data.data
						for(let i in this.listData){
							if(this.listData[i].Picurl==""||this.listData[i].Picurl==null){
								this.listData[i].Picurl="images/moren.png"
							}
						}
						
					}
				}).catch(function (error) {
					console.log(error); 
			})
		},
        //私教的签到
			pSignIn(id,currid){
				const params={
					id:id,
					currid:currid
				}
				sessionStorage.setItem('logo','0')
				axios.get('/mobileapi/coach/sign.php?act=sign',{params:params}).then(data => {
					console.log(data.data)
					let { msg, code} = data.data
						if (code !== 200) {
							window.vant.Toast.fail(msg)
						} else {
							window.vant.Toast.success("签到成功")
							this.getList()
						}
					}).catch(function (error) { 
						console.log(error); 
				})
			},
			//私教的取消预约
			pCancel(id,currid){
				const params={
					id:id,
					currid:currid
				}
				sessionStorage.setItem('logo','0')
				axios.get('/mobileapi/coach/sign.php?act=sign_pass',{params:params}).then(data => {
					console.log(data.data)
					let { msg, code} = data.data
						if (code !== 200) {
							window.vant.Toast.fail(msg)
						} else {
							window.vant.Toast.success("取消成功")
							this.getList()
						}
					}).catch(function (error) { 
						console.log(error); 
			})
		},
    }
})
</script>
</html>